//
//  RBSecurityVC.m
//  zhongzhenglu
//
//  Created by XL on 2022/7/15.
//

#import "RBSecurityVC.h"
#import "RBResetPasswordVC.h"
#import <UIColor+YYAdd.h>
#import "RBThemeConfig.h"
#import <UIControl+YYAdd.h>
#import "UIView+RBAdd.h"
#import "RBDefine.h"
#import <Masonry.h>
#import "UIButton+RBAdd.h"
#import "RBProfileVC.h"
#import "UIScrollView+RBAdd.h"

@interface RBSecurityVC ()

@property(nonatomic, strong)UIScrollView *scrollView;

@end

@implementation RBSecurityVC

#pragma mark - Lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self setup];
}

#pragma mark - Private

- (void)setup
{
    self.title = @"账号安全";
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem.alloc initWithImage:[[UIImage imageNamed:@"settingQuestion"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(questionBtnTapped)];
    [self.navigationItem.rightBarButtonItem setTitleTextAttributes:nil forState:UIControlStateNormal];
    self.view.backgroundColor = [UIColor colorWithHexString:@"#F2F2F2"];
    __weak typeof(self) weakSelf = self;
    [self.scrollView rbSetContentWidth:kRBMainScreenWidth];
    [self.scrollView addView:[self cellWithTitle:@"修改登录密码" des:nil block:^{
        RBResetPasswordVC *vc = RBResetPasswordVC.new;
        [weakSelf.navigationController pushViewController:vc animated:YES];
    }] withHeight:CGFLOAT_MIN width:kRBMainScreenWidth top:Zoom(10) bottom:0 left:0 right:0 centerX:0];
    [self.scrollView addView:[self cellWithTitle:@"修改支付密码" des:nil block:^{
        RBResetPasswordVC *vc = RBResetPasswordVC.new;
        [weakSelf.navigationController pushViewController:vc animated:YES];
    }] withHeight:CGFLOAT_MIN width:kRBMainScreenWidth top:0 bottom:0 left:0 right:0 centerX:0];
}

#pragma mark - Network

#pragma mark - Event

- (void)questionBtnTapped
{
    
}

#pragma mark - Setter

#pragma mark - Getter

- (UIScrollView *)scrollView
{
    if (!_scrollView)
    {
        self.scrollView = ({
            UIScrollView *view = UIScrollView.new;
            [self.view addSubview:view];
            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                make.edges.mas_equalTo(0);
            }];
            view;
        });
    }
    return _scrollView;
}

- (UIView *)cellWithTitle: (NSString *)title des: (NSString *)des block: (void(^)(void))block
{
    UIView *view = UIView.new;
    view.backgroundColor = UIColor.whiteColor;
    
    UILabel *titleL = ({
        UILabel *view = UILabel.new;
        view.font = [UIFont systemFontOfSize:Zoom(14)];
        view.textColor = [RBThemeConfig textBlackColor];
        view.text = title;
        view;
    });
    [view view_addView:titleL withHeight:CGFLOAT_MIN width:CGFLOAT_MIN top:Zoom(25) bottom:Zoom(25) left:Zoom(18) right:CGFLOAT_MIN centerX:0];
    
    UIImageView *arrowImgView = [UIImageView.alloc initWithImage:[UIImage imageNamed:@"mine_arrow_right"]];
    [view addSubview:arrowImgView];
    [arrowImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-Zoom(18));
        make.centerY.mas_equalTo(0);
        make.width.mas_equalTo(Zoom(7));
        make.height.mas_equalTo(Zoom(13));
    }];
    
    UILabel *desL = ({
        UILabel *view = UILabel.new;
        view.font = [UIFont systemFontOfSize:Zoom(12)];
        view.textColor = [UIColor colorWithHexString:@"#ACACAC"];
        view.text = des;
        view.textAlignment = NSTextAlignmentRight;
        view;
    });
    [view addSubview:desL];
    [desL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(arrowImgView.mas_left).offset(-Zoom(8));
        make.centerY.mas_equalTo(0);
        make.width.mas_equalTo(Zoom(200));
    }];

    UIButton *btn = UIButton.new;
    [view addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];
    [btn addBlockForControlEvents:UIControlEventTouchUpInside block:^(id  _Nonnull sender) {
        if (block)
        {
            block();
        }
    }];
    
    return view;
}

@end
